//
//  SortView.swift
//  HuaYun
//
//  Created by enghou on 2018/12/10.
//  Copyright © 2018 xyxorigation. All rights reserved.
//

import UIKit


class SortView: UIView {
    
    @IBOutlet weak var incomeRatioView: UIView!
    @IBOutlet weak var costRatioView: UIView!
    var delegate: IncomeCostProjects?
    
    enum SortType {
        case Ascending//升序
        case DeAscending//降序
        case UnKnown//未知
    }
    
    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
    }
    
    override func layoutSubviews() {
        super.layoutSubviews()
//        lftbtn.layer.masksToBounds = true
//        lftbtn.layer.cornerRadius = 3
//        lftbtn.layer.borderWidth = 0.5
//        lftbtn.layer.borderColor = UIColor.hex("eeeeee").cgColor
//        
//        rhtbtn.layer.masksToBounds = true
//        rhtbtn.layer.cornerRadius = 3
//        rhtbtn.layer.borderWidth = 0.5
//        rhtbtn.layer.borderColor = UIColor.hex("eeeeee").cgColor
    }
    
    @IBOutlet weak var lftbtn: UIButton!
    @IBOutlet weak var rhtbtn: UIButton!
    @IBAction func leftBtn(_ sender: Any) {
        if self.delegate != nil {
            self.delegate?.popleftselect()
        }
    }
    
    @IBAction func rightBtn(_ sender: Any) {
        if self.delegate != nil {
            self.delegate?.poprightselect()
        }
    }
    @IBOutlet weak var leftUpImage: UIImageView!
    @IBOutlet weak var leftDownImage: UIImageView!
    @IBOutlet weak var rightUpImage: UIImageView!
    
    @IBOutlet weak var rightDownImage: UIImageView!
    
    var incomecompleterate: SortType {
        set{
            switch newValue {
            case .Ascending:
                leftUpImage.image = UIImage(named: "up_click")
                leftDownImage.image = UIImage(named: "down_default")
            case .DeAscending:
                leftUpImage.image = UIImage(named: "up_default")
                leftDownImage.image = UIImage(named: "icon_down")
            default:
                leftUpImage.image = UIImage(named: "up_default")
                leftDownImage.image = UIImage(named: "down_default")
            }
        }
        get{
            return .UnKnown
        }
    }
    
    var badgecompleterate: SortType {
        set{
            switch newValue {
            case .Ascending:
                rightUpImage.image = UIImage(named: "up_click")
                rightDownImage.image = UIImage(named: "down_default")
            case .DeAscending:
                rightUpImage.image = UIImage(named: "up_default")
                rightDownImage.image = UIImage(named: "icon_down")
            default:
                rightUpImage.image = UIImage(named: "up_default")
                rightDownImage.image = UIImage(named: "down_default")
            }
        }
        get{
            return .UnKnown
        }
    }

}
